/*package com.zgq.share.thirdplatform.tencent;

import java.util.Map;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import com.zgq.share.thirdplatform.BasicAdapter;
import com.zgq.share.thirdplatform.IPlatform;
import com.zgq.share.thirdplatform.OAuthToken;
import com.zgq.share.thirdplatform.PlatformDefs;
import com.zgq.share.thirdplatform.Session;

*//**
 * 腾讯微博分享适配器
 * @author Administrator
 *
 *//*
public class TencentAdapter extends BasicAdapter implements IPlatform {

	private OAuthToken oauthtoken;
	private final static int REQUEST_CODE = 1;
	private String qqrequestToken;
	private String qqrequestTokenSecret;
	private String qqverifier;

	public TencentAdapter(Context context) {
		super(context);
		System.setProperty("TencentWeibo.oauth.consumerKey",
				PlatformDefs.TENCENT_CONSUMER_KEY);
		System.setProperty("TencentWeibo.oauth.consumerSecret",
				PlatformDefs.TENCENT_CONSUMER_SECRET);
		oauthtoken = new OAuthToken();
	}

	@Override
	public boolean supportLocation() {
		return true;
	}

	@Override
	public boolean supportImage() {
		return true;
	}

	@Override
	public boolean authenticate() { // 腾讯微博验证
		try {

			com.szy.weibo.service.Weibo weibo = new com.szy.weibo.service.Weibo();
			weibo.setTokenSecret(PlatformDefs.TENCENT_CONSUMER_KEY, PlatformDefs.TENCENT_CONSUMER_SECRET);
			// 获取未授权的Request Token
			Map<String, String> map = weibo.getRequestToken();

			// 获取oauth_tokenoauth_token和auth_token_secret
			qqrequestToken = map.get("oauth_token");
			qqrequestTokenSecret = map.get("oauth_token_secret");
			Log.i("request_token", "Request Token=" + qqrequestToken);
			Log.i("request_secret", "Request Token Secret="
					+ qqrequestTokenSecret);

			// 构造请求的URL
			StringBuilder urlBuilder = new StringBuilder();
			urlBuilder.append(PlatformDefs.TENCENT_AUTHORIZE_URL);
			urlBuilder.append("?");
			urlBuilder.append("oauth_token=" + qqrequestToken);

			// 利用singletop模式启动系统自带浏览器
			Intent intent = new Intent(context, WebViewActivity.class);
			Bundle bundle = new Bundle();
			bundle.putString("Tencenturl", urlBuilder.toString());
			Log.e("url", urlBuilder.toString());
			intent.putExtras(bundle);
			((Activity) context).startActivityForResult(intent, REQUEST_CODE);

			return true;

		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}

	@Override
	public boolean send(String title, String message, GeoPointEx point) {
		return false;
	}

	@Override
	public boolean validate() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public Session parseAuthResult(Intent intent) {
		com.szy.weibo.service.Weibo weibo = new com.szy.weibo.service.Weibo();
		qqverifier = WebViewActivity.VERIFIER;
		Map<String, String> map = weibo.getAccessToken(qqrequestToken,
				qqrequestTokenSecret, qqverifier);
		oauthtoken.setAccessToken(map.get("oauth_token"));
		oauthtoken.setAccessTokenSecret(map.get("oauth_token_secret"));

		if (!TextUtil.isEmpty(oauthtoken.getAccessToken())) {
			// 成功获取到accessToken和accessTokensecrect就存到session
			Session s = new Session();
			s.setToken(oauthtoken);
			s.setUid(qqverifier);


			WebViewActivity.webInstance.finish();
			getUserInfo();
			return s;

		}
		else{
			Toast.makeText(context, com.upengyou.itravel.ui.R.string.user_3rd_login_failed, Toast.LENGTH_SHORT).show();
		}
		return null;
	}

	*//**
	 * 获取授权登录用户信息，本地保存
	 *//*
	public void getUserInfo() {

		try {
			// 获取请求参数
			String paramsStr = OAuth.getPostParams(
					PlatformDefs.TENCENT_USERINFO_URL,
					PlatformDefs.TENCENT_METHOD, null,
					oauthtoken.getAccessToken(),
					oauthtoken.getAccessTokenSecret(), qqverifier, null,
					PlatformDefs.TENCENT_FORMAT, null, null, null,null);
			SyncHttp http = new SyncHttp();
			String response = http.httpGet(PlatformDefs.TENCENT_USERINFO_URL,
					paramsStr);

			if (response != null) {
				JSONObject obj_data = JSON.parseObject((JSON.parseObject(response))
						.getString("data"));
				String name = obj_data.getString("name");
				
				// 成功获取到accessToken和accessTokensecrect就存到数据库
				ShareSetting ss = new ShareSetting();
				ss.setName(PlatformDefs.TENCENT_NAME);
				ss.setUserID(name);
				ss.setToken(oauthtoken.getAccessToken());
				ss.setSecret(oauthtoken.getAccessTokenSecret());
				ss.setSelected(true);
				MyApplication.getInstance(context.getApplicationContext())
						.getShareSettings(context).add(ss);
				ssm = new ShareSettingManager(context);
				
				ssm.delete(PlatformDefs.TENCENT_NAME);
				ssm.add(ss);
				
				new ShareSetDialog(context, null, PlatformDefs.TENCENT_NAME);

				if (PlatformDefs.TENCENT_CALLBACK != null && PlatformDefs.TENCENT_CALLBACK.equals(UserLoginManagerActivity.TAG_NAME)) {
					accountHelper = MyApplication.getAccountHelper(context);
					String installId = accountHelper.getInstallId();
					
					com.upengyou.itravel.service.User user = new com.upengyou.itravel.service.User(context);
					CallResult cr = user.thirdPartyLogin(name, PlatformDefs.TENCENT_NAME, installId);
					if (callResult.getResult().equals("OK")) {
						MyApplication.getInstance(context).saveUserInfo((User)callResult.getData());
						Toast.makeText(context, com.upengyou.itravel.ui.R.string.user_login_success, Toast.LENGTH_SHORT).show();
					}
					saveTecent(cr, name);
					
				}
			}
		} catch (Exception e) {
			Log.i(Constants.TAG, e.getMessage());
			e.printStackTrace();
		}

	}

	@Override
	public boolean authenticate(String callback) {
		// TODO Auto-generated method stub
		return false;
	}
	
	private void saveTecent(CallResult cr, String name) {
		
		if (cr.isSuccess()) {
			if (cr.isWhetherbind()) {
				User u = (User) cr.getData();
				MyApplication.getInstance(context).saveUserInfo(u);
				accountHelper.setThirdLogin(true);
				accountHelper.save(context);
				Toast.makeText(context, R.string.user_login_success, Toast.LENGTH_SHORT).show();
			} else {
				Intent intent = new Intent(context, UserLoginBindingActivity.class);
				intent.putExtra(Defs.NAME, name);
				intent.putExtra(Defs.TYPE, PlatformDefs.TENCENT_NAME);
				context.startActivity(intent);
			}
		}
	}

}
*/